package com.qf.boot1.controller;

import com.qf.boot1.config.TencentOssProperty;
import com.qf.boot1.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zed
 * @date 2022/5/18 10:11
 * 控制器类
 */
@RestController
public class HelloController {

    // java提供的注入注解
    @Resource
    User user;

    // @Value可以获取配置文件中的内容 ${配置文件中配置项的key}
    @Value("${name}")
    String name;

    @Value("${age}")
    Integer age;

    @Value("${addr}")
    String addr;

    @Resource
    TencentOssProperty ossProperty;

    @GetMapping("/hello")
    public String hello() {
        return "Hello SpringBoot!";
    }

    @GetMapping("/user")
    public User queryUser() {
        return user;
    }

    @GetMapping("/oss")
    public TencentOssProperty tencentOss() {
        return ossProperty;
    }

    @GetMapping("/info")
    public String userInfo() {
        return name + "," + age + "," + addr;
    }
}
